package com.qf.service.impl;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.cache.annotation.CacheKey;
import com.netflix.hystrix.contrib.javanica.cache.annotation.CacheRemove;
import com.netflix.hystrix.contrib.javanica.cache.annotation.CacheResult;
import com.qf.feign.GoodsFeign;
import com.qf.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 千锋教育
 * @Company http://www.mobiletrain.org/
 * @Version 1.0
 */
@Service
public class TestServiceImpl implements TestService {

    @Autowired
    GoodsFeign goodsFeign;


    @CacheResult
    @HystrixCommand(commandKey = "testCache")
    @Override
    public String test(Integer id) {
        String query = goodsFeign.query(id);
        return query;
    }

    @Override
    @HystrixCommand
    @CacheRemove(commandKey = "testCache")
    public String clearCache(@CacheKey  Integer id) {
        return null;
    }


}
